package com.zdxlz.fcmp.common.core.constant.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Description：操作类型枚举
 * @Author： aman
 * @Date： 2025/3/7 13:44
 */
@Getter
@AllArgsConstructor
public enum OperateTypeEnum {

    INSERT(1, "新增"),
    UPDATE(2, "修改"),
    DELETE(3, "删除"),
    SELECT(4, "查询"),
    SEND_MESSGE(5, "发布消息"),
    SUBSCRIBE_MESSGE(6, "订阅消息"),
    IMPORT(7, "导入"),
    EXPORT(8, "导出"),
    OTHER(100, "其他"),
    ;

    @EnumValue
    private final Integer code;
    private final String name;

    public static OperateTypeEnum getByCode(Integer code) {
        for (OperateTypeEnum operateTypeEnum : OperateTypeEnum.values()) {
            if (operateTypeEnum.getCode() == code) {
                return operateTypeEnum;
            }
        }
        return null;
    }

    @JsonValue
    public int getCode() {
        return code;
    }
}
